(function () {
  "use strict";
  var allButton = document.body.querySelectorAll(".button.is-dark");

  // 批量执行点击事件
  function buttonClick(timer) {
    const button =  Array.from(allButton).filter(item=>['evolution-rna','evolution-dna'].indexOf(item.parentElement.id)>=0)
    const result = {}

    result.interval = setInterval(() => {
        button.forEach(item=>{
            item.click()
        })
    }, timer)

    result.timeout = button.length === 2 ? null : setTimeout(() => {
        allButton = document.body.querySelectorAll(".button.is-dark");
    }, 1000 * 30);
    return {
        interval,
        timeout
    }
  }

  var {interval,timeout} = buttonClick()

  // 创建按钮以及输入框动态设置RNA以及DNA的点击频率
  const input = document.createElement("input");
  input.placeholder = '请输入RNA以及DNA点击频率，单位毫秒，默认100毫秒'
  input.style.width = '300px'
  const button = document.createElement("button");
  button.style = 'margin-right: 10px;'
  button.innerHTML = '设置点击频率'
  button.onclick = () => {
    const value = input.value
    if (value) {
      clearInterval(interval)
      timeout && clearInterval(timeout);
      ({interval,timeout} = buttonClick(100))
    }
  };
  const inputBox = document.createElement("div");
  inputBox.appendChild(button)
  inputBox.appendChild(input)
  inputBox.style = 'display: flex;position: fixed;top: 30%;left: 10%;'
  document.body.appendChild(inputBox)
})();
